package cn.flexui.flexuiserver.controller.web;

import cn.flexui.flexuiserver.common.ResponseResultGenerator;
import cn.flexui.flexuiserver.common.convert.FlexChatResponseConvert;
import cn.flexui.flexuiserver.domain.FlexChatResponse;
import cn.flexui.flexuiserver.domain.ResponseResult;
import cn.flexui.flexuiserver.domain.entity.ChatRecord;
import cn.flexui.flexuiserver.service.ChatRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 对话记录 前端控制器
 * </p>
 *
 * @author apeto
 * @since 2024-09-17 07:08:21
 */
@Tag(name = "对话记录")
@RestController
@RequestMapping("/chatRecord")
public class ChatRecordController {

    @Autowired
    private ChatRecordService chatRecordService;
    @Autowired
    private FlexChatResponseConvert flexChatResponseMapper;


    @Operation(summary = "根据reqId查询列表")
    @GetMapping("/list/{requestId}")
    public ResponseResult<List<FlexChatResponse>> list(@PathVariable String requestId) {
        List<ChatRecord> chatRecords = chatRecordService.selectRequestId(requestId);
        return ResponseResultGenerator.success(flexChatResponseMapper.toFlexChatResponseList(chatRecords));
    }
}
